package org.example.myframework.frame.demo.controller;

import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.example.myframework.frame.common.entity.R;
import org.example.myframework.frame.demo.domain.base.PageRo;
import org.example.myframework.frame.demo.domain.pojo.ro.TestTablePlusRo;
import org.example.myframework.frame.demo.service.TestTablePlusService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RequestMapping("/tablePlus")
@RestController
@Api(value = "tablePlus测试接口", tags = {"tablePlus测试接口"})
@Slf4j
public class TestTablePlusController {

    @Resource
    private TestTablePlusService testTablePlusService;

    @PostMapping("/save")
    public R save(@RequestBody TestTablePlusRo ro) {
        Boolean b = testTablePlusService.saveEntity(ro);
        return R.ok(b);
    }

    @DeleteMapping("/delete")
    public R delete(@RequestParam Long id) {
        Boolean b = testTablePlusService.deleteById(id);
        return R.ok(b);
    }

    /**
     * 集成mybatis测试
     * @return 测试列表
     */
    // @LogAnnotation(value = "获取测试列表")
    // @GetMapping("/getTestList")
    // @ApiOperation(value = "获取测试列表")
    // public List<TestTable> getList() {
    //     return testTableService.getList();
    // }

    /**
     * 获取分页列表
     * @param ro
     * @return
     */
    @PostMapping("/page")
    public R page(@RequestBody PageRo<TestTablePlusRo> ro) {
        return R.ok(testTablePlusService.getPage(ro));

    }

    /**
     *
     * @param id
     * @return
     */
    @GetMapping("/getById")
    public R getById(@RequestParam Long id) {
        log.info("<UNK>id<UNK>{}", id);
        return R.ok(testTablePlusService.getByTableId(id));
    }



}
